
var SEPARATION = 100,
    AMOUNTX = 60,
    AMOUNTY = 40;
var container;
var camera, scene, renderer;
var particles, particle, count = 0;
var mouseX = 0,
    mouseY = 0;
var windowHalfX = window.innerWidth / 2;
var windowHalfY = window.innerHeight / 2;

$(function () {

    change(); //验证码
});


//验证码
function change() {
    code = $("#code");
    // 验证码组成库
    var arrays = new Array(
        '1', '2', '3', '4', '5', '6', '7', '8', '9', '0',
        'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
        'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
        'u', 'v', 'w', 'x', 'y', 'z',
        'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
        'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
        'U', 'V', 'W', 'X', 'Y', 'Z'
    );
    codes = ''; // 重新初始化验证码
    for (var i = 0; i < 4; i++) {
        // 随机获取一个数组的下标
        var r = parseInt(Math.random() * arrays.length);
        codes += arrays[r];
    }
    // 验证码添加到input里
    code.val(codes);
    $('#captcha').val(codes)
}

$('#submit').off('click').on('click', function (e) {
    e.preventDefault()
    var name = $('#name').val()
    var psw = $('#psw').val()
    var code = $('.code').val()
    var captcha = $('#captcha').val()
    if (!name) {
        alert('请填写用户名')
        return false
    }
    if (name !== 'admin') {
        alert('用户名错误')
        return false
    }
    if (!psw) {
        alert('请填写密码')
        return false
    }
    if (psw !== '123') {
        alert('密码错误')
        return false
    }
    if (!code) {
        alert('请填写验证码')
        return false
    }
    if (code !== captcha) {
        alert('验证码输入错误')
        return false
    }
    alert('登陆成功')
    window.location.href = "index.html"
})